<?php

namespace api\user\controller;

class AdminChatController extends \Aaa\user\controller\AdminChatController {

    protected function init() {
        $this->baseField = [
            [
                'field' => 'id',
                'name' => 'ID',
            ],
            [
                'field' => 'from_user_id',
                'name' => '发消息用户',
            ],
            [
                'field' => 'to_user_id',
                'name' => '收消息用户',
            ],
            [
                'field' => 'user_id',
                'name' => '双方 逗号分隔',
            ],
            [
                'field' => 'create_time',
                'name' => '消息时间',
                'type' => 'time',
            ],
            [
                'field' => 'type',
                'name' => '消息类型',
                'type' => 'select',
                'options' => [
                    ['name' => '文本', 'value' => 'text'],
                    ['name' => '图片', 'value' => 'image'],
                ],
            ],
            [
                'field' => 'content',
                'name' => '内容',
            ],
            [
                'field' => 'avatar',
                'name' => '头像',
                'type' => 'image',
            ],
            [
                'field' => 'read',
                'name' => '已读',
                'type' => 'switch',
                'options' => [ '已读','未读'],
            ],
        ];
    }

    protected function beforeIndex() {
        $this->actionField = ['id', 'from_user_id', 'to_user_id', 'create_time', 'type', 'content', 'read',];
        $this->searchField = [
            'common' => [
                'id' => 'accurate',
                'from_user_id' => 'accurate',
                'to_user_id' => 'accurate',
                'user_id' => 'accurate',
                'type' => 'accurate',
                'content' => 'fuzzy',
                'read' => 'accurate',
            ],
            'time' => ['create_time'],
        ];
    }

}